package com.cait.cait.dao;

import com.cait.cait.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * @author Jirath
 * @date 2020/2/16
 * @description:
 */
@Repository
public interface UserDao {
    /**
     * 新User，密码000000
     * @param user 用户信息,不含密码
     */
    @Insert("INSERT INTO user (member_id,username) VALUES (#{memberId},#{username}")
    void newUser(User user);

    /**
     * select allMsg according to username
     * @param username
     * @return
     */
    @Select("SELECT * FROM user WHERE username=#{username}")
    User getPasByUsername(String username);

    /**
     * update password according to userID;
     * @param user userMsg
     */
    @Update("UPDATE user SET user_password=#{userPassword} WHERE member_id=#{memberId}")
    void updatePasswordById(User user);

    /**
     * update username(member's studentId) according to id;
     * @param user userMsg
     */
    @Update("UPDATE user SET username=#{username} WHERE member_id=#{memberId}")
    void updateUsernameById(User user);

    /**
     * del UserMsg according to userId;
     * @param memberId member database stored Id
     */
    @Delete("DELETE FROM user WHERE member_id=#{memberId)")
    void delUserById(Integer memberId);
}
